package com.edu.d3_collection_traversal;

import java.util.ArrayList;
import java.util.Collection;

public class foreachDemo {
    /**
     * 增强for循环的使用,可以用来遍历数组、集合
     */
    public static void main(String[] args) {
        //遍历集合
        Collection<String> list = new ArrayList<>();
        list.add("黑马");
        list.add("程序员");
        list.add("123");
        list.add("奥特曼");
        list.add("迪迦");
        System.out.println(list);
        for (String s : list) {
            System.out.println(s);
        }
        System.out.println("-------------------");
        //遍历数组
        int[] scores={10,20,30,40,50,60,70,80,90};
        for (int score : scores) {
            System.out.println(score);
        }
    }
}
